<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--使用CDN方式引入vue-->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.4/vue.min.js"></script>
</head>
<body>
<h1>指令部分综合案例</h1>
<hr>
<div id="app">
    <div class="menu" v-for="(item,index) in menuList" :key="index" @mouseleave="item.isShow=false">
        <div class="menu_title" @mouseover="item.isShow=true">{{item.title}}</div>
        <div class="menu_sub" v-show="item.isShow" @mouseover="item.isShow=true"
             v-for="(subItems,index2) in item.subMenu" :key="index2" @click="showMenuInfo(index,index2)">
            {{subItems}}
        </div>
    </div>
</div>

<script>
    let vm = new Vue({
        el: '#app',
        data: {
            menuList: [
                {
                    title: '公司简介',
                    subMenu: [
                        '发展历程',
                        '公司文化',
                        '公司招聘'
                    ],
                    isShow: false
                },
                {
                    title: '产品介绍',
                    subMenu: [
                        '银行',
                        '保险',
                        '工业'
                    ],
                    isShow: false
                },
                {
                    title: '投资者关系',
                    subMenu: [
                        '公司股票',
                        '公司章程',
                        '公司财务'
                    ],
                    isShow: false
                }
            ]
        },

        methods: {
            showMenuInfo(index, index2) {
                //console.log(this);
                console.log(index + "," + index2);
                //console.log(this.menuList);
                console.log(this.menuList[index].subMenu[index2]);
            }
        }
    })
</script>
<style>
    #app {
        margin: 0px auto;
        width: 480px;
        height: auto;
        display: flex;
        justify-content: space-around;
    }

    .menu {
        width: 160px;
        height: auto;
        padding: 0px;
        /*background: aliceblue;*/
        cursor: pointer;
    }

    .menu .menu_title {

        width: 100%;
        height: 40px;
        text-align: center;
        line-height: 40px;
        background: orange;
        color: #FFF;
    }

    .menu .menu_sub {
        width: 100%;
        height: 40px;
        text-align: center;
        line-height: 40px;
        background: aliceblue;
        color: #666;
    }
</style>
</body>
</html>
